using UnityEngine;
using ControllerTypeValue = System.Int32;

namespace Life.UI.MVC.Loader
{
    public abstract class UILoader : MonoBehaviour
    {
        public bool Initialized
        {
            get;
            private set;
        } = false;
        public event System.Action OnInitialized;
        
        private void Awake()
        {
            if (!Initialized)
            {
                OnInitialize(OnInitializedCallback);
            }
        }

        private void OnInitializedCallback()
        {
            Initialized = true;
            OnInitialized?.Invoke();
            OnInitialized = null;
        }
        
        protected abstract void OnInitialize(System.Action callback);
        public abstract GameObject Load(ControllerTypeValue token);
    }
}